<?php
    require_once(APPPATH . '/controllers/test/Toast.php');
    class group_attributes extends Toast{

        function __construct()
        {
            parent::__construct(__FILE__);
        }

        /**
        * Duplicate attribute name
        * 
        * Check for duplicate attribute name in all object groups attributes on description form
        * 
        */
        public function test_check_duplicate_name()
        {
            $this->load->model('object_groups_model');
            $this->load->model('group_attributes_model');

            // GET DESCRIPTION GROUPS ON OBJECT 
            $object_groups = $this->object_groups_model->find_descriptions_groups(2);

            // Get each object group
            $group_attributes = array();
            foreach ($object_groups as $object_group) :
                //Get description groups on object type of hotel
                //$this->firephp->log(gettype($object_group['group_ID']));
                $group_attributes[$object_group['group_ID']] = $this->group_attributes_model->get_attributes_on_group($object_group['group_ID']);

                endforeach;

                
            $this->firephp->log($group_attributes); 
            foreach ($group_attributes as $key=>$group_attribute) {
                $this->firephp->log($key);
                foreach ($group_attribute as $group_attribut) {
                    $attribute_name = $key.$group_attribut['attribute_name'];
                    $counter = 0;

                    foreach ($group_attributes as $key2=>$grp_attribute) {
                        //$this->firephp->log($group_attribute);
                        foreach ($grp_attribute as $grp_attribut) {
                            
                            
                            if($key2.$grp_attribut['attribute_name']==$attribute_name){
                                $this->firephp->log($key2.$grp_attribut['attribute_name'].":".$attribute_name);
                                $counter++;
                                if($counter>1){
                                    $this->_fail('This should not heppend :). Counter is+'.$counter." Attribute is:".$attribute_name);
                                }
                            }
                            
                        }
                    }

                }
            }

        }
    }
?>
